package com.laf.manager.querycondition.member;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.math.BigDecimal;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class MemberFilterCondition {

    private String username = "";

    private String mobile = "";

    private String carNumber = "";

    private String birthdayMonth = "";

    private long registerDateStart;

    private long registerDateEnd;

    private Integer level = -1;

    private Integer occupation = -1;

    private BigDecimal cumulateAmountStart;

    private BigDecimal cumulateAmountEnd;

    private int cumulatePointsStart;

    private int cumulatePointsEnd;

    private long birthdayStart;

    private String Start;

    private long birthdayEnd;

    private String End;

    private int status = -1;

    private int mallId = 0;

    private int size = 10;

    private int page = 1;

    private String sort;
    private String asc;
    private String count;
    private String sex;

//    public Long getRegisterDateStart() {
//        return registerDateStart == null? 0L : registerDateStart;
//    }

    public long getRegisterDateStart() {
        return registerDateStart;
    }

    public void setRegisterDateStart(long registerDateStart) {
        this.registerDateStart = registerDateStart;
    }

    public long getRegisterDateEnd() {
        return registerDateEnd + getTime();
    }

    public void setRegisterDateEnd(long registerDateEnd) {
        this.registerDateEnd = registerDateEnd;
    }
//
//    public Long getBirthdayStart() {
//        return birthdayStart == null ? 0L : birthdayStart;
//    }
//
    public long getBirthdayEnd() {
        return birthdayEnd + getTime();
    }

    public void setBirthdayEnd(long birthdayEnd) {
        this.birthdayEnd = birthdayEnd;
    }

    public void setBirthdayStart(long birthdayStart) {
        this.birthdayStart = birthdayStart;
    }

    public long getBirthdayStart() {
        return birthdayStart;
    }

    public BigDecimal getCumulateAmountStart() {
        return cumulateAmountStart == null ? new BigDecimal(0D) : cumulateAmountStart;
    }

    public BigDecimal getCumulateAmountEnd() {
        return cumulateAmountEnd == null ? new BigDecimal(0D) : cumulateAmountEnd;
    }

    public int getOffset() {
        return (page - 1) * size;
    }

    public String getStart() {
        return Start;
    }

    public void setStart(String start) {
        Start = start;
    }

    public String getEnd() {
        return End;
    }

    public void setEnd(String end) {
        End = end;
    }

    private long getTime() {
        long time = (((23 * 60 + 59) * 60) + 59) * 1000;

        return time;
    }

    public MemberFilterCondition clone() {
        MemberFilterCondition mfc = new MemberFilterCondition();
        mfc.setUsername(this.username);
        mfc.setMobile(this.mobile);
        mfc.setCarNumber(this.carNumber);
        mfc.setBirthdayMonth(this.birthdayMonth);
        mfc.setRegisterDateStart(this.registerDateStart);
        mfc.setRegisterDateEnd(this.registerDateEnd);
        mfc.setLevel(this.level);
        mfc.setOccupation(this.occupation);
        mfc.setCumulateAmountStart(this.cumulateAmountStart);
        mfc.setCumulateAmountEnd(this.cumulateAmountEnd);
        mfc.setCumulatePointsStart(this.cumulatePointsStart);
        mfc.setCumulatePointsEnd(this.cumulatePointsEnd);
        mfc.setBirthdayStart(this.birthdayStart);
        mfc.setBirthdayEnd(this.birthdayEnd);
        mfc.setStatus(this.status);
        mfc.setMallId(this.mallId);
        mfc.setSize(this.size);
        mfc.setPage(this.page);
        mfc.setSort(this.sort);
        mfc.setAsc(this.asc);
        mfc.setCount(this.count);
        mfc.setSex(this.sex);
        return mfc;
    }
}
